﻿using Clipboard.Model;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using Clipboard.Model.Enum;

namespace Clipboard.Tools
{
    public class ClipboardRecordTemplateSelector : DataTemplateSelector
    {

        public DataTemplate ImageTemplate { get; set; }
        public DataTemplate TextTemplate { get; set; }
        public DataTemplate FileTemplate { get; set; }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            var record = item as ClipboardRecord;  // ClipboardRecord 是你绑定的数据项类型
            if (record == null)
                return base.SelectTemplate(item, container);

            // 根据 Type 字段返回不同的 DataTemplate
            switch (record.DataType)
            {
                case TypeEnum.Imges:
                    return ImageTemplate;
                case TypeEnum.Text:
                    return TextTemplate;
                case TypeEnum.Document:
                    return FileTemplate;
                default:
                    return base.SelectTemplate(item, container);
            }
        }
    }
}
